#include "sip-server-cfg.h"

server_cfg::server_cfg()
{
    mstr_sip_server_codeid = "34020000002000000001";
    mstr_sip_server_domain = "3402000000";
    mstr_sip_host = "0.0.0.0";
    mus_sip_port = 35061;
    mstr_dev_unified_access_password = "12345678";
}

server_cfg::~server_cfg()
{

}

bool server_cfg::set_sip_server_cfg(std::string &str_sip_id, std::string &str_sip_domain, std::string &str_sip_host, unsigned short us_sip_port, std::string &str_password)
{
    mo_mutex.lock();
    mstr_sip_server_codeid = str_sip_id;
    mstr_sip_server_domain = str_sip_domain;
    mstr_sip_host = str_sip_host;
    mus_sip_port = us_sip_port;
    mstr_dev_unified_access_password = str_password;
    mo_mutex.unlock();

    return true;
}

bool server_cfg::get_sip_server_cfg(std::string &str_sip_id, std::string &str_sip_domain, std::string &str_sip_host, unsigned short &us_sip_port, std::string &str_password)
{
    mo_mutex.lock();
    str_sip_id = mstr_sip_server_codeid;
    str_sip_domain = mstr_sip_server_domain;
    str_sip_host = mstr_sip_host;
    us_sip_port = mus_sip_port;
    str_password = mstr_dev_unified_access_password;
    mo_mutex.unlock();

    return true;
}

bool server_cfg::get_sip_server_sip_info(std::string &str_sip_id, std::string &str_sip_domain)
{
    mo_mutex.lock();
    str_sip_id = mstr_sip_server_codeid;
    str_sip_domain = mstr_sip_server_domain;
    mo_mutex.unlock();

    return true;
}

bool server_cfg::get_sip_server_host(std::string &str_sip_host, unsigned short &us_sip_port)
{
    mo_mutex.lock();
    str_sip_host = mstr_sip_host;
    us_sip_port = mus_sip_port;
    mo_mutex.unlock();

    return true;
}

bool server_cfg::get_sip_server_unified_access_password(std::string &str_password)
{
    mo_mutex.lock();
    str_password = mstr_dev_unified_access_password;
    mo_mutex.unlock();

    return true;
}

bool server_cfg::set_media_server_cfg(std::string &str_ip, unsigned short us_port)
{
    mo_mutex.lock();
    mstr_media_server_ip = str_ip;
    mus_media_server_port = us_port;
    mo_mutex.unlock();

    return true;
}

bool server_cfg::get_media_server_cfg(std::string &str_ip, unsigned short &us_port)
{
    mo_mutex.lock();
    str_ip = mstr_media_server_ip;
    us_port = mus_media_server_port;
    mo_mutex.unlock();

    return true;
}
